From f7a6244cc1a8f39ad44186a4da6b743ab6821d51 Mon Sep 17 00:00:00 2001
From: Linnnus <linnnus@users.noreply.github.com>
Date: Wed, 19 Feb 2025 18:37:33 +0100
Subject: Add assignment submission

---
 .../routes/assignments/[assignmentId]/+page.svelte | 30 ++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

(limited to 'app/src/routes/assignments/[assignmentId]/+page.svelte')

diff --git a/app/src/routes/assignments/[assignmentId]/+page.svelte b/app/src/routes/assignments/[assignmentId]/+page.svelte
index 0b36a19..9cf9890 100644
--- a/app/src/routes/assignments/[assignmentId]/+page.svelte
+++ b/app/src/routes/assignments/[assignmentId]/+page.svelte
@@ -1,5 +1,7 @@
 <script lang="ts">
+	import { enhance } from "$app/forms";
 	import type { PageProps } from "./$types";
+	import { canBeFinished } from "$lib/common/assignments";
 
 	let { data }: PageProps = $props();
 
@@ -12,14 +14,38 @@
 
 <h1>Assignment #{data.assignment.id}</h1>
 <p>
-	Gravstedet, der skal vedligeholdes er ved <span class="address">{data.cemetaryPlot.address}</span
-	>.
+	Gravstedet, der skal vedligeholdes er ved
+	<span class="address">{data.cemetaryPlot.address}</span>.
 </p>
 <p>Vedligeholdelsen skal finde sted <time>{assignmentDate}<time>.</time></time></p>
+<p>State: {data.assignment.state}</p>
+
+<h2>Færdiggør opgave</h2>
+{#if canBeFinished(data.assignment)}
+	<p>Når du har færdiggjort opgaven, kan du uploade billederne her:</p>
+	<form method="POST" action="?/finish" enctype="multipart/form-data" use:enhance>
+		<label>
+			Billeder:
+			<input type="file" name="images" accept=".jpg, .jpeg, .png, .webp" required multiple />
+		</label>
+		<label>
+			Ekstra bemærkninger:
+			<textarea name="notes" placeholder="F.eks.: Vi løb tør for roser (?). De kommer i overmorgen :)"
+			></textarea>
+		</label>
+		<button>Færddigør job</button>
+	</form>
+{:else}
+	<p>Du har færddigjort denne opgave!</p>
+{/if}
 
 <style>
 	.address,
 	time {
 		font-weight: bold;
 	}
+
+	label {
+		display: block;
+	}
 </style>
-- 
cgit v1.2.3

